$(function(){
	$(document).on('click','#addposition',function(){
		    var name = document.getElementById("name").value;
			var info = document.getElementById("info").value;
			var salary = document.getElementById("salary").value;
			var sector_id = document.getElementById("sector_id").value;
	
			var param = {
				name: name,
                info: info,
				salary: salary,
				sector_id: sector_id
			};
			$.ajax({
				url: '/person/index.php/Home/addposition/positionAdd',
				type: 'POST',
				dataType: 'json',
				data: param,
				success: function(data){
					console.log(data);
					if(data.code == 0){
						layer.msg('添加成功',{icon: 1});						
					}
				},
				error: function(xhr){
					console.log(xhr);
				}
			});
	});

	$(document).on('click','#editposition',function(){


            var id = document.getElementById("id").value;
		    var name = document.getElementById("name").value;
			var info = document.getElementById("info").value;
			var salary = document.getElementById("salary").value;
			var sector_id = document.getElementById("sector_id").value;
	
			var param = {
				id: id,
				name: name,
                info: info,
				salary: salary,
				sector_id: sector_id
			};
			$.ajax({
				url: '/person/index.php/Home/Editposition/positionEdit',
				type: 'POST',
				dataType: 'json',
				data: param,
				success: function(data){
					console.log(data);
					if(data.code == 0){
						layer.msg('修改成功',{icon: 1});						
					}
				},
				error: function(xhr){
					console.log(xhr);
				}
			});
	});
});